﻿/**
 * 
 * @file SARibbonBarHelper.h
 * @brief  SARibbonBar 相关设置
 * @author LiBaojun (libaojunqd@foxmail.com)
 * @date 2024-10-13
 * 
 */
#ifndef _SARIBBON_BAR_HELPER_H___
#define _SARIBBON_BAR_HELPER_H___
 
#include "GUIFrameAPI.h"
#include <QString>
#include <QObject>
#include <QHash>

class QWidget;
class QAction;
class SARibbonBar;

namespace GUI
{
    class MainWindow;
    /**
     * @brief SARibbonBar 相关设置
     * @author LiBaojun (libaojunqd@foxmail.com)
     * @date 2024-10-13
     */
    class GUIFRAMEAPI SARibbonBarHelper : public QObject
    {
        Q_OBJECT;
    public:
        /**
         * @brief  模块类型枚举
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-01-14
         */
        enum GUIModuleType
        {
            None,
            File,
            Edit,
            Geo,
            Material,
            PhysicalProp,
            SubSys,
            Junction,
            Load,
            SolveAndResult,
            Script,
            Tool,
            Window,
            Help,
        };
        Q_ENUM(GUIModuleType);
        /**
         * @brief Construct a new SARibbonBarHelper object
         * @param[i]  mw             主页面
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-13
         */
        explicit SARibbonBarHelper(MainWindow* mw);
        /**
         * @brief Destroy the SARibbonBarHelper object
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-13
         */
        virtual ~SARibbonBarHelper() = default;

        /**
        * @brief 初始化Ribbon页面
        * @author LiBaojun (libaojunqd@foxmail.com)
        * @date 2024-10-12
        */
        void initRibbonBar();
        /**
         * @brief    切换Ribbon至指定模块
         * @param[i] module                    模块类型
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-01-14
         */
        void switchToModule(GUIModuleType module);
        /**
         * @brief    获取当前Ribbon模块
         * @return   GUIModuleType             模块类型
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-01-14
         */
        SARibbonBarHelper::GUIModuleType getCurrentModuleType();
    private:
        /**
      * @brief 创建action
      * @param[i]  text           字符提示
      * @param[i]  name           对象名称
      * @param[i]  icon           图标
      * @param[i]  parent         父对象
      * @return QAction*
      * @author LiBaojun (libaojunqd@foxmail.com)
      * @date 2024-10-12
      */
        static QAction* CreateAction(const QString& text, const QString & name,
            const QString& icon, QWidget* parent = nullptr);
        /**
        * @brief 初始化开始菜单
        * @author LiBaojun (libaojunqd@foxmail.com)
        * @date 2024-10-12
        */
        void initRibbonBarStartButton();

        /**
         * @brief 初始化文件页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        void initRibbonBarFile();
        /**
         * @brief 初始化编辑页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-11-15
         */
        void initRibbonBarEdit();
        /**
         * @brief 初始化编辑页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-11-15
         */
        void initRibbonBarGeo();
        /**
         * @brief 初始化材料页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        void initRibbonBarMaterial();
        /**
         * @brief 初始化属性页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        void initRibbonBarPhysicalProp();
        /**
         * @brief 初始化子系统页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        void initRibbonBarSubSys();
        /**
         * @brief    初始化连接页
         * @author   BaGuijun (baguijun@163.com)
         * @date     2024-11-12
         */
        void initRibbonBarJunction();
        /**
         * @brief 初始化载荷页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-11-15
         */
        void initRibbonBarLoad();
        /**
         * @brief 初始化求解与结果页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-11-15
         */
        void initRibbonBarSolveAndResult();
        /**
         * @brief 初始化脚本页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-11-15
         */
        void initRibbonBarScript();
        /**
         * @brief 初始化工具页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-11-15
         */
        void initRibbonBarTool();
        /**
         * @brief 初始化窗口页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-11-15
         */
        void initRibbonBarWindow();
        /**
         * @brief 初始化帮助页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-11-15
         */
        void initRibbonBarHelp();
        /**
         * @brief    单选数据
         * @param[i] actionList 动作链表
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-10
         */
        void checkActionSingly(QList< QAction* > actionList);
        /**
         * @brief    Ribbon中Gategory索引记录(用于切换)
         * @param[i] type                     Gategory类型
         * @return   void
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-01-14
         */
        void recordGategoryIndex(GUIModuleType type);
    private:
        /**
         * @brief 主界面
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-13
         */
        MainWindow* _mainWindow{};
        /**
         * @brief ribbon栏
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-13
         */
        SARibbonBar* _ribbonBar{};
        /**
         * @brief Ribbon中gategory的索引
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-10-13
         */
        static int _gategoryIndex;
        /**
         * @brief Ribbon下gategory的索引与名称记录
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-10-13
         */
        QHash<QString, int> _gategoryHash = {};
    };
}


#endif
